package StudyCode.summary.myfile;

import java.io.*;
import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class SerializingAnObject {
	public static void main(String[] args) {
		Object object = new javax.swing.JButton("push me");
		try {
			ObjectOutput out = new ObjectOutputStream(new FileOutputStream("filename.ser"));
			out.writeObject(object);
			out.close();

			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			out = new ObjectOutputStream(bos);
			out.writeObject(object);
			out.close();

			byte[] buf = bos.toByteArray();
			System.out.println(Arrays.toString(buf));
		} catch (IOException ignored) {
		}
	}
}
